
import Vue from 'vue'

const throttling = Vue.directive('throttling', {
    inserted: function (el, binding) {
        el.addEventListener('click', () => {
            if (!el.disabled) {
                el.disabled = true;
                el.style.pointerEvents = 'none';
                setTimeout(() => {
                    el.disabled = false;
                    el.style.pointerEvents = 'unset';
                }, binding.value || 2000)
            }
        })
    }
});

export { throttling }
